<?
require("config.php");

$location_status .= "| Edit";

$show_backnav = "brand_menu";

$menuname = NULL;

$menutarget = NULL;

if (NULL!=$action){

   $table = "pro_brand";

	$dir = "$table/";

	myUpload($Logo1,$Logo1_name,$dir);
	myUpload($Logo2,$Logo2_name,$dir);
	myUpload($Picture,$Picture_name,$dir);

	if ($Logo1_name == null) $Logo1_name = $bk_Logo1;
	if ($Logo2_name == null) $Logo2_name = $bk_Logo2;
	if ($Picture_name == null) $Picture_name = $bk_Picture;

	if ($remove_Logo1=="ture") $Logo1_name=NULL;
	if ($remove_Logo2=="ture") $Logo2_name=NULL;
	if ($remove_Picture=="ture") $Picture_name=NULL;


   $field = array(
	"code", 
	"name", 
	"logo1", 
	"logo2",
	"picture",
	);


   $content = array(
	$Code,
	$Name,
	$Logo1_name,
	$Logo2_name,
	$Picture_name,
	);

   $expression = "id = $id";

   myUpdate($table,$field,$content,$expression);

   header("location:" . $rela_path . "share/msg.php?v=5");

}else{
	$Query = "select * from pro_brand where id='$id'";
	$r = myQuery($Query);

	if (!$r)header("location:" . $rela_path . "share/msg.php?v=9002");

	$Code = $r[0][1];
	$Name = $r[0][2];
	$Logo1 = $r[0][3];
	$Logo2 = $r[0][4];
	$Picture = $r[0][5];

}

require($rela_path . "inc/header.php");

?>

<table width="95%" border="0" align="center">
  <tr> 
    <td align="right">&nbsp; </td>
  </tr>
  <tr> 
    <td>
	<form action="" method="post" enctype="multipart/form-data" name="form1">
	
	<table width="100%" border="0" cellspacing="1" cellpadding="1">
        <tr> 
          <td class="tdheader">Code : </td>
          <td><input type="text" class="text" name="Code" size="40" value="<?print($Code)?>">

		  <input name="action" type="hidden" value="edit">
		  <input name="id" type="hidden" value="<?print($id)?>">
		  <input name="bk_Logo1" type="hidden" value="<?print($Logo1)?>"> 
		  <input name="bk_Logo2" type="hidden" value="<?print($Logo2)?>"> 
		  <input name="bk_Picture" type="hidden" value="<?print($Picture)?>"> 

		</td>
        </tr>
        <tr> 
          <td class="tdheader">Name :</td>
          <td><input type="text" class="text" name="Name" size="40" value="<?print($Name)?>"></td>
        </tr>
        <tr> 
          <td class="tdheader">Logo 1 :</td>
          <td><?loadImage($Logo1,$rela_path . $PIC_DIR . "$table/")?>
		  <?removeImage($Logo1,"remove_Logo1")?>
		  <input name="Logo1" type="File" class="text" id="Logo1" size="40" value=<?print($Logo1)?>>
          </td>
        </tr>
        <tr> 
          <td class="tdheader">Logo 2 :</td>
          <td><?loadImage($Logo2,$rela_path . $PIC_DIR . "$table/")?>
		  <?removeImage($Logo2,"remove_Logo2")?>
		  <input name="Logo2" type="File" class="text" id="Logo2" size="40">
          </td>
        </tr>
        <tr> 
          <td class="tdheader">Picture :</td>
          <td><?loadImage($Picture,$rela_path . $PIC_DIR . "$table/")?>
		  <?removeImage($Picture,"remove_Picture")?>
		  <input name="Picture" type="File" class="text" id="Picture" size="40">
          </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td><input type="image" src="../../images/bt_cancel.gif" onClick="Redirect('brand_menu.php',1);;return false;"> 
            <input type="image" src="../../images/bt_save.gif"></td>
        </tr>
      </table>
	  </form>
      <p><br>
        <br>
        <br>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp; </p></td>
  </tr>
</table>
<?
require($rela_path . "inc/footer.php");
?>
